﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace WeatherServiceLibrary.Code
{
    [DataContract]
    public class Observation
    {
        private List<StationObservation> statObs;

        [DataMember]
        public List<StationObservation> StationObservations
        {
            get { return statObs; }
            set { }
        }
        private DateTime _timestamp;

        [DataMember]
        public DateTime Timestamp
        {
            get { return _timestamp; }
            set { }
        }


        public Observation(DateTime timestamp)
        {
            using (DBA.WeatherDB.WeatherBaseDataContext db = new DBA.WeatherDB.WeatherBaseDataContext())
            {

                var stationObservations = db.StationObservations.Where(x => timestamp == x.Timestamp).ToList();
                var query = from x in stationObservations select new StationObservation(x);
                statObs = query.ToList();
            }
            _timestamp = timestamp;
        }

    }
}
